import { useAppDispatch, useAppSelector } from '@/store/hooks'
import { increment, decrement } from '@/store/slices/counterSlice'

export default function Counter() {
  const { value } = useAppSelector(state => state.counter) // state获取了所有的模块，这里取其中的counter
  const dispatch = useAppDispatch() // 用以调用不同模块中的方法
  return (
    <div>
      {value}
      <hr />
      <button
        onClick={() => {
          dispatch(increment())
        }}
      >
        +
      </button>
      <button
        onClick={() => {
          dispatch(decrement())
        }}
        
      >-</button>
    </div>
  )
}
